<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>

  <body>
    <script src="js/jquery.js"></script>
    <script>
    //引入jquery库，用$.ajax发起请求
    function promiseCreator(url) {
      return new Promise(function (resolve, reject) {
        $.ajax({
          url: url,
          success: function (data) {
            resolve(data);
          },
          error: function (err) {
            reject(err);
          },
        });
      });
    }

  promiseCreator('https://api.github.com/')
    .then(function (data) {
      console.log(data); //获取第一层数据
      return promiseCreator(data.emojis_url);
    })
    .then(function (data2) {
      console.log(data2); //获取第二层数据
      return promiseCreator(data2.book);
    })
    .then(function (data3) {
      console.log(data3); //获取第三层数据
    });
    </script>
  </body>
</html>
